package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingLevelDto;
import com.zzyl.entity.NursingLevel;
import com.zzyl.service.NursingLevelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import com.zzyl.service.NursingProjectService;
import com.zzyl.vo.NursingLevelVo;
import com.zzyl.vo.NursingPlanVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import com.zzyl.service.NursingProjectService;
import com.zzyl.vo.NursingLevelVo;
import com.zzyl.vo.NursingPlanVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import static com.zzyl.base.ResponseResult.success;

/**
 * @Description NursingLevelController
 * @Author Haiying Ji
 * @Date 2025-08-31
 */
@RestController
@RequestMapping("/nursingLevel")
@Api(tags = "护理等级管理")
@Slf4j
public class NursingLevelController extends BaseController {

    @Autowired
    private NursingLevelService nursingLevelService;

    @PostMapping("/insert")
    public ResponseResult insertNursingLevel(@RequestBody NursingLevelVo nursingLevelVo){
        nursingLevelService.insertNursingLevel(nursingLevelVo);
        return success();}

    @PutMapping("/update")
    @ApiOperation("修改护理等级")
    public ResponseResult updateById(@RequestBody NursingLevelDto nursingLevelDto){
        log.info("修改护理等级,等级id：{}",nursingLevelDto.getId());

        nursingLevelService.updateById(nursingLevelDto);

        return ResponseResult.success();
    }

    @GetMapping("/listByPage")
    public ResponseResult<NursingLevelVo> selectByPage(NursingLevelDto nursingLevelDto) {
        List<NursingLevelVo> nursingLevels = nursingLevelService.selectByPage(nursingLevelDto);
        return success(PageResponse.of(nursingLevels));}
    @DeleteMapping("/delete/{id}")
    @ApiOperation("删除护理等级")
    public ResponseResult deleteById(@PathVariable Integer id){
        log.info("删除护理等级,护理等级id：{}",id);
        nursingLevelService.deleteById(id);
        return success();
    }

    @GetMapping("/{id}")
    public ResponseResult<NursingLevelVo> selectById(@PathVariable Long id) {
        NursingLevelVo nursingLevelVo = nursingLevelService.selectById(id);
        return success(nursingLevelVo);}
    @PutMapping("/{id}/status/{status}")
    @ApiOperation("启用禁用护理等级")
    public ResponseResult changeStatus(@PathVariable Long id,@PathVariable Integer status) {
        log.info("启用禁用护理等级,id:{},status:{}",id,status);
        nursingLevelService.changeStatus(id,status);
        return ResponseResult.success();
    }

}
